﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: ISelfContainingObject.cs
//
//  Description: Interface for persistents holding their state internally.
// 
//--------------------------------------------------------------------------

using System;

namespace Chili.Opf3
{
	/// <summary>
	/// A class implementing this interface is self containing (manages the state by
	/// itself) and can be remoted or persisted to any kind of device without problems.
	/// </summary>
	/// <remarks>
	/// 	<para>This interface is implemented by classes that are (or should be) independent
	///     of any <see cref="Opf3.ObjectContext">ObjectContext</see> instance.</para>
	/// 	<para>Usually a class "lives" within one
	///     <see cref="Opf3.ObjectContext">ObjectContext</see>, as that context internally
	///     holds the state (loaded, saved, deleted, marked for deletion, ..) of the object. By
	///     implementing this interface the <see cref="Opf3.ObjectContext">ObjectContext</see>
	///     saves that information directly in the object and does not hold it internally. Each
	///     time the object is saved (or any other thing is done on the object that requires
	///     the <see cref="Opf3.ObjectContext">ObjectContext</see>) the context gets the data
	///     directly from the object itself. This makes it independent from the
	///     <see cref="Opf3.ObjectContext">ObjectContext</see>.</para>
	/// 	<para>Usually this interface is implemented by classes that are remoted, serialized
	///     or persisted to any kind of device (other then the storage). It could be optionally
	///     implemented by any persistent object to have it independent from its
	///     <see cref="Opf3.ObjectContext">ObjectContext</see>.</para>
	/// </remarks>
	/// <example>
	///     The following example shows a class that implements the interface. 
	///     <code lang="CS">
	/// [Persistent("USER")]
	/// public class User : ISelfContainingObject
	/// {
	///     private ObjectInfo _objectInfo = null;
	///  
	///     public ObjectInfo ObjectInfo
	///     {
	///         get { return _objectInfo; }
	///         set { _objectInfo = value; }
	///     }
	///  
	///     // ... Other properties and fields.
	/// }
	///     </code>
	/// </example>
	public interface ISelfContainingObject
	{
		/// <summary>
		/// Returns the <see cref="Opf3.ObjectInfo">ObjectInfo</see> object that contains all
		/// information required to make the persistent object
		/// <see cref="Opf3.ObjectContext">independent from any ObjectContext</see>.
		/// </summary>
		/// <value>
		/// 	<see cref="Opf3.ObjectInfo">ObjectInfo</see> object that holds the status
		/// information of the persistent object.
		/// </value>
		ObjectInfo ObjectInfo
		{
			get;
			set;
		}
	}
}
